home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / contrib / doc / w_outline.el < prev    next >
Encoding:
Text File  |  1991-10-06  |  2.5 KB  |  65 lines

  1. ;; Copyright (C) 1991 Bob Weiner
  2. ;; WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  3. ;; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  4. ;;
  5. ;; Permission to use, copy, modify, distribute, and sell this software and
  6. ;; its documentation for any purpose is hereby granted without fee,
  7. ;; provided that the above copyright notice appear in all copies and that
  8. ;; both that copyright notice and this permission notice appear in
  9. ;; supporting documentation, and that the name of Hewlett-Packard, Niels
  10. ;; Mayer, Brown University and Bob Weiner not be used in advertising or
  11. ;; publicity pertaining to distribution of the software without specific,
  12. ;; written prior permission.  Hewlett-Packard, Niels Mayer, Brown University
  13. ;; and Bob Weiner makes no representations about the suitability of this
  14. ;; software for any purpose.  It is provided "as is" without express or
  15. ;; implied warranty.
  16. ;;
  17. ;; This file is not part of GNU Emacs.
  18. ;;
  19.  
  20. ;;; Date: Wed, 19 Dec 90 04:43:24 -0500
  21. ;;; From: rsw@cs.brown.edu (Bob Weiner)
  22. ;;; Message-Id: <9012190943.AA07371@reverb.cs.brown.edu>
  23. ;;; To: mayer@hplnpm.hpl.hp.com
  24. ;;; Subject: Function to extract outline from structured text documents.
  25. ;;; 
  26. ;;; I noticed in your Winterp doc that you must use Emacs outlining mode a good
  27. ;;; deal, otherwise, why would you nest so much?
  28. ;;; 
  29. ;;; If you do, you'll probably find this function indispensible.  Try it.
  30. ;;; 
  31. ;;; Here's a sample output so you get the idea:
  32. ;;; * WINTERP <--> Motif Widget Classes
  33. ;;; ** WIDGET_CLASS -- the WINTERP widget metaclass.
  34. ;;; *** equivalent Xt 'WidgetClass':
  35. ;;; *** equivalent creation convenience function:
  36. ;;; *** XtCreateWidget():
  37. ;;; *** XtSetValues():
  38. ;;; *** XtGetValues():
  39. ;;; *** XtAddCallback():
  40.  
  41. (global-set-key "\C-x4o" 'outline-extract)
  42. (defun outline-extract ()
  43.   "[weiner] Copy outline structure from current buffer to \"/tmp/otl\".
  44. Assume bodies in current buffer are already hidden.  This allows the user to
  45. select the levels of the outline that are copied.  Otherwise, use {M-x
  46. hide-body} when in outline-mode, to hide everything but headings."
  47.   (interactive)
  48.   (let ((start) (end)
  49.     (obuf (current-buffer))
  50.     (buf (get-buffer-create "/tmp/otl")))
  51.     (save-excursion 
  52.       (goto-char (point-min))
  53.       (while (progn (setq start (point))
  54.             (re-search-forward "[
  55. \n]" nil t))
  56.     (backward-char 1)
  57.     (setq end (point))
  58.     (set-buffer buf)
  59.     (insert-buffer-substring obuf start end)
  60.     (insert "\n")
  61.     (set-buffer obuf)
  62.     (forward-line 1)))
  63.     (pop-to-buffer buf)
  64.     (goto-char (point-min))
  65.     (delete-matching-lines " ")))
  66.